<?php if (! defined('BASEPATH')) exit('No direct script access allowed');

class Books extends CI_Controller {
	public function __construct() {
		parent::__construct();
        $this->load->model('book_model');
        $this->load->model('bookuser_model');
        $this->load->model('comment_model');
	}

    public function index() {
        $id = filter_input(INPUT_GET,'id',FILTER_VALIDATE_INT);
        $data['id'] = $id;
        $data['uid'] = isset($_SESSION['uid'])&&!empty($_SESSION['uid'])?$_SESSION['uid']:0;
        $data['uname'] = isset($_SESSION['uname'])&&!empty($_SESSION['uname'])?$_SESSION['uname']:"";
        $book_info = $this->book_model->getBooks($id);
        $data["attr"] = array("author"=>"作者","publisher"=>"出版社","pubdate"=>"出版时间","isbn"=>"ISBN编号","binding"=>"装帧","pages"=>"页数");
        $data["book_info"] = $book_info[0];
        $data["comment"] = $this->comment_model->getCommentByBookId($id);
        
        $data["book_user"] = $this->bookuser_model->getUserByBookId($id);
        $this->load->view('books',$data);
    }
}

?>